package com.micro.train.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.micro.train.entity.Train;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 火车信息数据访问接口
 */
@Mapper
public interface TrainRepository extends BaseMapper<Train> {
    
    /**
     * 根据车次查询列车信息
     */
    Train selectByTrainNumber(@Param("trainNumber") String trainNumber);
    
    /**
     * 根据车次号查询车次ID
     */
    Long selectTrainIdByTrainNumber(@Param("trainNumber") String trainNumber);
    
    /**
     * 根据列车类型查询
     */
    List<Train> selectByTrainType(@Param("trainType") String trainType);
    
    /**
     * 根据始发站ID查询
     */
    List<Train> selectByDepartureStationId(@Param("departureStationId") Long departureStationId);
    
    /**
     * 根据终点站ID查询
     */
    List<Train> selectByTerminalStationId(@Param("terminalStationId") Long terminalStationId);
    
    /**
     * 根据状态查询
     */
    List<Train> selectByStatus(@Param("status") Integer status);
    
    /**
     * 根据始发站和终点站查询
     */
    List<Train> selectByRoute(@Param("departureStationId") Long departureStationId, 
                             @Param("terminalStationId") Long terminalStationId);
    
    /**
     * 检查车次是否存在
     */
    boolean existsByTrainNumber(@Param("trainNumber") String trainNumber);
}
